#!C:\Python25\python.exe

from cgi import *
import ConfigParser
import string, os, sys


cfg = ConfigParser.ConfigParser()
cfg.read("path.cfg")
templatepath = cfg.get("template", "path")
reportpath = cfg.get("report", "path")
resultpath = cfg.get("result", "path")

print "Content-type: text/html \n\n"
print """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
      <title>Handovers System</title>
      <style type="text/css">
         body {
            font-family: Verdana, Tahoma, Sans-serif;
            font-size: 10pt;
             margin-top: 0;
             margin-left: 0;
         }
         
          div.title {
             float:right;
            font-weight:bold;
            margin-top: 18px;
            clear: left;
            padding-right: 20px;
            color:#FFFFFF;
            background-color: #39638B
         }
         
          #banner {
             margin-top: 0;
             margin-left: 0;
             background-image: url('/handovericu/images/top_banner_in02.gif');
             background-position: 227px;
            background-repeat: no-repeat;
            background-color:#39638B; 
         }
         #title {
             font-family: Arial, Tahoma, Sans-serif;
             margin-top: 10px;
             margin-left: 5px;
             margin-bottom: 10px;
             font-weight: bold;
             font-size: 12pt;
         }

      </style>      
   </head>
   
   <body>
      <div id='banner'>
           <div> 
            <a href='http://www.usyd.edu.au'>
                <img src='/handovericu/images/top_banner_in01.gif' width='227' height='52' alt='The University of Sydney' style='border: 0px;' class='decor' /> 
            </a>
         </div>
      </div>
      <div id='title'>
         Handovers System
      </div>

<form name='template_form' action="hoc.py" method="post">
<BR><B>Choose Template</B>   
<select name="template">
"""
dirList=os.listdir(templatepath)
for fname in dirList:
    print "<option value=\"" + fname[0:len(fname)-4] + "\">" + fname[0:len(fname)-4] + "</option>"
print """
</select>
<BR><BR>
<B>Choose Report Type</B>
<input type="radio" name="printall" value="Single" checked="checked" > Single with MRN=
<input type='text' size='30' name='MRN' /> 
<input type="radio" name="printall" value="Bedno"> Single with Bed No.=
<input type='text' size='30' name='bedno' /> 
<input type="radio" name="printall" value="All"> ALL Current Patients
<BR><BR>    
<B>Output to</B><input type="radio" name="outputtype" value="Browser" checked="checked"> Browser
<input type="radio" name="outputtype" value="HtmlFile"> HtmlFile
<input type="radio" name="outputtype" value="XMLFile"> XMLFile
<input type='submit' value='Generate' style='margin-top: 3px;' />                
      </form>
<HR />

<div id=report>
<form name='result_form' action="hoc.py" method="post">
<BR><B>Choose Existing Report</B>   
<select name="result">
"""

dirList=os.listdir(resultpath)
for fname in dirList:
    print "<option value=\"" + fname[0:len(fname)-4] + "\">" + fname[0:len(fname)-4] + "</option>"

print """
</select>
<BR><BR>
Output to <input type="radio" name="outputtype" value="Browser" checked="checked"> Browser
<input type="radio" name="outputtype" value="HtmlFile"> HtmlFile
<input type='submit' value='Generate' style='margin-top: 3px;' />                
      </form>
</div>

   </body>
</html>
"""


